import Vue from 'vue';
import axios from "axios";
//dev
let baseURL='/zhiran'
export function AxiosNetwork(method, url, params, data, success, failure){
  const zrAxios = axios.create({
    method:method,
    baseURL:baseURL,
    data:data,
    params:params,
    withCredentials:false,
  })

  //拦截器
  zrAxios.interceptors.request.use(
      (config)=> {
        // Do something before request is sent
        return config;
      },
      (error)=>{
        // Do something with request error
        return Promise.reject(error);
      }
  );


  // Add a response interceptor
  zrAxios.interceptors.response.use(
      function(response) {
        // Do something with response data
        return response;
      },
      function(error) {
        // Do something with response error
        return Promise.reject(error);
      }
  );

   zrAxios(url)
      .then((response)=>{
        success(response)
      })
      .catch((error)=>{
        failure(error)
      })
}




